SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


create procedure dbo.DnnProduct_DeleteHtmlTextUsers

as

delete
from   DnnProduct_HtmlTextUsers
where  HtmlTextUserID in 
  ( select HtmlTextUserID
    from   DnnProduct_HtmlTextUsers
    inner join dbo.DnnProduct_HtmlText on dbo.DnnProduct_HtmlTextUsers.ItemID = dbo.DnnProduct_HtmlText.ItemID
    where DnnProduct_HtmlTextUsers.ItemID = DnnProduct_HtmlText.ItemID
    and DnnProduct_HtmlTextUsers.StateID <> DnnProduct_HtmlText.StateID )

GO
